package com.qa.controller;

import com.qa.pojo.Article;
import com.qa.pojo.Category;
import com.qa.service.IArticleService;
import com.qa.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @Author
 * @Date 2020/3/2 9:44
 * @Desc
 **/
@Controller
public class PageController {
    @Autowired
    private ICategoryService categoryService;
    @Autowired
    private IArticleService articleService;


    @GetMapping("/cms/index")
    public String cmsIndex(){
        return "cmsIndex";
    }

    @GetMapping("/reception/index")
    public String receptionIndex(Model model) {
        List<Category> categoryList = categoryService.getByStatus();
        model.addAttribute("categoryList", categoryList);
        List<Article> articleList = articleService.getByRandom();
        model.addAttribute("articleList", articleList);
        return "index";
    }

    @GetMapping("/contact")
    public String contact() {
        return "contact";
    }


}
